<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<div class="content-wrap">
    <div class="wrapper" style="bottom: 50px;">
        <ul class="nav nav-tabs">
            <li>
                <a href="#"  onclick="loadDiv('mainCenterDiv','${ctx}/csm/expSupplierCata/index')">消耗品厂商列表</a>
            </li>
            <li class="active">
                <a href="#" onclick="loadDiv('mainCenterDiv','${ctx}/csm/expSupplierCata/form')">
                    <c:choose>
                        <c:when test="${expSupplierCata.id==''|| expSupplierCata.id==null}">
                            消耗品厂商添加
                        </c:when>
                        <c:otherwise>消耗品厂商修改</c:otherwise>
                    </c:choose>
                </a>
            </li>
        </ul>
        <section class="panel panel-default">
            <div class="panel-body">
                <div class="col-lg-12">
                    <form:form id="inputForm" data-parsley-validate="" modelAttribute="expSupplierCata" onsubmit="return formSaveLoad('mainCenterDiv','inputForm','${ctx}/csm/expSupplierCata/save','${ctx}/csm/expSupplierCata/index');" method="post" enctype="multipart/form-data" class="form-horizontal">
                        <form:hidden path="id"/>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">供应商别名：</label>
                            <div class="col-sm-4">
                                <form:input path="supplierJc" htmlEscape="false" class="form-control"  maxlength="100" data-parsley-required="true"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">厂商：</label>
                            <div class="col-sm-4">
                                <form:input path="supplierName" htmlEscape="false" class="form-control"  maxlength="40" data-parsley-required="true"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">厂商类别：</label>
                            <div class="col-sm-4">
                                <form:select path="supplierClass" class="form-control" data-parsley-required="true">
                                    <form:option value="" label=""/>
                                    <form:options items="${fns:getDictList('SUPPLIER_CLASS')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                                </form:select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">供应商地址：</label>
                            <div class="col-sm-4">
                                <form:input path="supplierAddress"  htmlEscape="false" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">邮编：</label>
                            <div class="col-sm-4">
                                <form:input path="supplierPostalCode"  htmlEscape="false" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">法人姓名：</label>
                            <div class="col-sm-4">
                                <form:input path="aptificialPerson"  htmlEscape="false" class="form-control"  maxlength="20" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">联系电话：</label>
                            <div class="col-sm-4">
                                <form:input path="linkPhone"  htmlEscape="false" class="form-control" maxlength="20" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">营业执照号：</label>
                            <div class="col-sm-4">
                                <form:input path="licenceNo"  htmlEscape="false" class="form-control" maxlength="20" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">营业执照期限：</label>
                            <div class="col-sm-4">
                                <input  path="licenceDate" htmlEscape="false" class="form-control Wdate" readonly
                                       onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value='<fmt:formatDate value="${expSupplierCata.licenceDate}" pattern="yyyy-MM-dd HH:mm:ss"/>' />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">生产经营许可证号：</label>
                            <div class="col-sm-4">
                                <form:input path="permitNo"  htmlEscape="false" class="form-control" maxlength="20" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">许可证期限：</label>
                            <div class="col-sm-4">
                                <input id="permitDate" path="permitDate" htmlEscape="false" class="form-control Wdate" readonly
                                       onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value='<fmt:formatDate value="${expSupplierCata.permitDate}" pattern="yyyy-MM-dd HH:mm:ss"/>' />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">备注信息：</label>
                            <div class="col-sm-6">
                                <form:textarea path="remarks" htmlEscape="false" rows="3" maxlength="200" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存">&nbsp;
                                <input id="btnCancel" class="btn" type="button" value="返 回" onclick="loadDiv('mainCenterDiv','${ctx}/csm/expSupplierCata/index')">
                            </div>
                        </div>
                    </form:form>
                </div>

            </div>
        </section>
    </div>
</div>
<script>
    function formSaveMethod(divId, formId, url, hrefUrl) {
        url=timestamp(url);
        hrefUrl=timestamp(hrefUrl);
        if (flag) {
            flag = false;
            formSubmitInput(formId);
            $("#" + formId + " input,#" + formId + " select").removeAttr("disabled");
            $("#" + formId).ajaxSubmit({
                type: 'post', // 提交方式 get/post
                url:url, // 需要提交的 url
                success: function(data) { // data 保存提交后返回的数据，一般为 json 数据
                    if (data.code == "success") {
                        toastr.success(data.data);
                        loadDiv(divId, hrefUrl);
                    } else if(data.code == 'info'){
                        toastr.info(data.data);
//                        loadDiv(divId, hrefUrl);
                    } else {
                        flag = true;
                        toastr.error(data.data);
                    }
                }
            });
        }
        return false;
    }
</script>